package com.zhuozhou.jdyc.main.meinfo.adapter;

import android.content.Context;

import com.zhuozhou.jdyc.R;
import com.zhuozhou.jdyc.base.BaseRecyclerViewAdapter;
import com.zhuozhou.jdyc.base.BaseViewHolder;
import com.zhuozhou.jdyc.databinding.AdapterCouponBinding;
import com.zhuozhou.jdyc.main.meinfo.bean.MyDiscountBean;
import com.zhuozhou.jdyc.wight.dialog.adapter.CouponAdapter;
import com.zhuozhou.jdyc.wight.recyclerview.MyLayoutManager;

/**
 * Create by CherishTang on 2020/3/27 0027
 * describe:首页菜单adapter
 */
public class MyCouponAdapter extends BaseRecyclerViewAdapter<MyDiscountBean, AdapterCouponBinding> {
    public MyCouponAdapter(Context context) {
        super(context);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.adapter_coupon;
    }

    @Override
    public void onBindViewHolder(BaseViewHolder baseViewHolder, int pos) {
        super.onBindViewHolder(baseViewHolder, pos);
    }

    @Override
    public void onBindHolder(BaseViewHolder<AdapterCouponBinding> holder, int pos) {
        holder.getBinding().tvMerchant.setText(mList.get(pos).getNickname());
        CouponAdapter couponAdapter = new CouponAdapter(mContext);
        couponAdapter.setText("去使用");
        couponAdapter.setList(mList.get(pos).getDiscount());
        if (mOnItemClickListener != null)
            couponAdapter.setOnCouponItemClickListener((view, position) -> {
                mOnItemClickListener.onItemClick(view, pos);
            });
        holder.getBinding().mRecyclerViewCoupon.setAdapter(couponAdapter);
        holder.getBinding().mRecyclerViewCoupon.setLayoutManager(new MyLayoutManager(mContext));
    }

}
